package com.openim.web.controller;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.std.StdArraySerializers;
import com.openim.api.Api;
import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.Userinfos;
import com.taobao.api.request.OpenimUsersAddRequest;
import com.taobao.api.response.OpenimUsersAddResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by 甘叶勇 on 2016/7/13.
 */
@Controller
@RequestMapping("/index")
public class IndexController {
    @RequestMapping(value = "/openIm", method = RequestMethod.GET)
    public String index(Model model, @RequestParam(required = false) String id) {
        if(StringUtils.isEmpty(id)) {
            id = "imuser123";
        }
        model.addAttribute("uid", id);
        model.addAttribute("credential", "123456");
        model.addAttribute("appKey", Api.APP_KEY);
        model.addAttribute("tid", 1781268535L);

        return "index";
    }

    public static void main(String[] args) throws ApiException {

    }

}
